package www.test.utils;

import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;



public class BeanListHandler 
{
	
	

	
	public static List<HashMap<String, ?>> handler(ResultSet rs)
	{
		try
		{
			List<HashMap<String, ?>> list = new ArrayList<HashMap<String,?>>();
			while(rs.next())
			{
				
				//得到结果集元数据
				ResultSetMetaData metaDate =rs.getMetaData();
				int count = metaDate.getColumnCount();
				HashMap group = new HashMap();
				for(int i = 0 ;i<count ;i++)
				{
					String name =metaDate.getColumnName(i+1);
					Object value=rs.getObject(name);
					group.put(name, value);
				}
				list.add(group);
			}
			return list;
		}
		catch (Exception e)
		{
			throw new RuntimeException(e);
		}
		
	}

	

}
